<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="vue.js"></script>
    <title>Document</title>
    <style>
        .ball {
            width: 15px;
            height: 15px;
            background-color: hotpink;
            border-radius: 50%;
        }
    </style>
</head>

<body>
    <div id="app">
        <com2 @func="show"></com2>
    </div>
    <template id="tem1">
        <div>
            <h1>这是子组件</h1>
            <input type="button" value="子组件的按钮，点击触发父组件的方法" @click="myclick">
        </div>
    </template>
</body>

<script>
    var com2 = {
        template: '#tem1',
        methods: {
            myclick() {
                this.$emit('func')
            }
        }
    }

    var vm = new Vue({
        el: '#app',
        data: {
            msg: '父组件中的内容'
        },
        components: {
            com2
        },
        methods: {
            show() {
                console.log('父组件方法show被调用')
            }
        }

    })
</script>

</html>